import Mock, {Random} from 'mockjs';
import {output} from '../help';

export function makeItem() {
  const name = Random.ctitle(5, 10);
  const types = ['公司直发', '天猫代金劵', '门店代金劵'];
  return {
    id: Random.increment(),
    name,
    type: types[parseInt(Math.random() * 3)],
  };
}

Mock.mock(/mock.queryLotteryList/, () => {

  let list = [];
  for (let i = 0; i < 6; i++) {
    list.push(makeItem());
  }

  return output({
    list,
    total: 6,
  });
});

Mock.mock(/mock.getLotteryResult/, () => {
  const types = ['公司直发', '天猫代金劵', '门店代金劵'];
  let code = '';
  for (let i = 0; i < 9; i++) {
    code += parseInt(Math.random() * 10);
  }
  return output({
    rtoken: 'asdasdgweasd',
    award: {
      type: types[parseInt(Math.random() * 3)],
      name: '这是一个商品',
      id: parseInt(Math.random() * 6 + 1),
      code,
    },
  });
});

Mock.mock(/mock.getWinnerDetail/, () => {
  return output({
    result: true,
  });
});




